<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <input type="text" @keydown="hi('hello')" />
        <hr />
        按键别名
        <input type="text" @keydown.enter="hi('enter')" />
        <hr />
        键码
        <input type="text" @keydown.65="hi($event.keyCode)" />
        <hr />
        键码->别名
        <input type="text" @keydown.keya="hi($event.keyCode)" />
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      // 定义键码别名
      Vue.config.keyCodes.keya = 65;
      new Vue({
        el: "#app",
        template: "#t1",
        data: {},
        methods: {
          hi(e) {
            console.log(e);
          },
        },
      });
    </script>
  </body>
</html>
